<?php
/**
 * Ueditor编辑器
 * User: dxk
 * Date: 2020/07/17
 */
namespace App\Http\Controllers\Service;

use App\Http\Controllers\Controller;
use App\Library\Service\Ueditor;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Crypt;

class UeditorController extends Controller
{
    /**
     * 后端配置
     * 参照后端请求规范：http://fex.baidu.com/ueditor/#dev-request_specification
     * @param Request $request
     */
    public function index(Request $request)
    {
        $Ueditor = new Ueditor();
        $easy_param = trim($request->input('easy_param'));
        if (!empty($easy_param)) {
            $param = Crypt::decrypt($easy_param);
            if (isset($param['folder']) && !empty($param['folder'])) {
                $Ueditor->setFolder(trim($param['folder']));
            }
            if (isset($param['type']) && !empty($param['type'])) {
                $Ueditor->setType(trim($param['type']));
            }
            if (isset($param['user']) && !empty($param['user'])) {
                $Ueditor->setOperateBy(trim($param['user']));
            }
        }
        $Ueditor->dispatch();
    }
}
